﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<%@ Import Namespace="LoveMusic" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <link href="/Views/Images/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <link href="/Views/Images/favicon.ico" rel="icon" type="image/x-icon" />
    <title>One click play music - we play the music You love - ilovethismusic.com</title>
    <meta name="description" content="We play only the music you love" />
    <meta name="keywords" content="Music,Song,Listen,Download,Vote,Discover,Mp3,Audio,Video" />
    <script type="text/javascript">
        window.onload = function () {
            var element = document.getElementById('q');
            try {
                element.focus();
            }
            catch (err) {
            }
        };
    </script>
    <style type="text/css">
        *
        {
            margin: 0;
            padding: 0;
            font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif;
        }
        
        html
        {
            height: 100%;
        }
        
        body
        {
            background-color: #E3E3E3;
        }
        
        #wrapper
        {
            font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif;
            width: 63%;
            margin-right: auto;
            margin-left: auto;
            margin-top: 0.7%;
            margin-bottom: 0.7%;
            border: 1px solid #CACACA;
            text-align: center;
            background-color: #FFFFFF;
        }
        
        
        #header
        {
            color: #ffffff; /*width: 100%;          position: absolute;*/
            height: 77px;
            background-image: url('/Song/ImageStatic/bg_header.jpg/1/1/' );
            background-repeat: repeat-x;
        }
        
        #header .title
        {
            font-family: "Trebuchet MS" ,Sans-Serif,Verdana;
            font-size: 36px;
            font-weight: bolder;
            padding-left: 0px;
            padding-top: 0px;
            float: left;
            height: 79px;
        }
        
        .dhtmlselect
        {
            /*style of DHTML Select Menu, main box */
            width: 98%;
            height: 38px;
            position: relative;
            text-indent: 3px;
            padding: 1px 0;
            cursor: hand;
            cursor: pointer; /* background-color: #F0F0F0; */
            font-size: 24px;
            border: 1px solid #98d1e9;
        }
        
        .dhtmlselect .option
        {
            /*style of Drop Down Menu that appears onMouseover */
            height: 45px;
        }
        
        .searchBox
        {
            width: 98%;
            min-width: 350px;
            height: 38px;
            font-size: 26px; /*background: #ffffff url('/Song/ImageStatic/search.gif/1/1') no-repeat scroll 3px 4px;*/
            border: 1px solid #98d1e9;
        }
        
        .playButton
        {
            cursor: hand;
            cursor: pointer;
            font-size: 4.1em;
        }
        
        .clouds
        {
            background-color: #CDCDCD;
        }
        
        .moodCloud
        {
            text-align: justify;
            line-height: 32px;
        }
        
        .moodCloud a
        {
            text-decoration: none;
            padding: 0pt 2px 0pt 2px;
            font-weight: bold;
            white-space: nowrap;
            color: #656565; /*color: #105CB6; */
        }
        
        .moodCloud a:hover
        {
            /*background-color: #105CB6;*/
            background-color: #646464; /*color: #ffffff; */
            color: #6BCEFE;
        }
        
        .songCloud
        {
            text-align: justify;
            line-height: 32px;
        }
        
        .songCloud a
        {
            text-decoration: none;
            padding: 0pt 2px 0pt 2px;
            font-weight: bold;
            white-space: nowrap;
            color: #656565;
        }
        
        .songCloud a:hover
        {
            background-color: #646464;
            color: #6BCEFE;
        }
        
        .artistCloud
        {
            text-align: justify;
            line-height: 32px;
        }
        
        .artistCloud a
        {
            text-decoration: none;
            padding: 0pt 2px 0pt 2px;
            font-weight: bold;
            white-space: nowrap;
            color: #656565;
        }
        
        .artistCloud a:hover
        {
            background-color: #646464;
            color: #6BCEFE;
        }
        
        .form
        {
            /* border: 1px solid #E2E2E2;*/
            padding: 8px 8px 8px 8px;
            width: 100%;
        }
        .form h2
        {
            font-size: 16px;
            font-weight: bold;
            padding-bottom: 2px;
            margin-bottom: 2px;
            font-variant: small-caps;
        }
        .promo
        {
            font-size: 15px;
            color: black;
            line-height: 1.5;
        }
        #subContainer
        {
            margin-top: 40px;
            text-align: left;
        }
        #promoText
        {
            float: left;
            width: 370px;
            padding-left: 25px;
            padding-right: 25px;
        }
        .mainTitle
        {
            color: #D51007;
            font-size: 22px;
        }
        #facebookLikes
        {
            float: right;
        }
        #searchBox
        {
            margin-top: 180px;
            margin-bottom: 40px;
        }
        #footer-spacer
        {
            clear: both;
            padding: 5px 10px;
        }
        
        #footer
        {
            clear: both;
            border-width: thick medium medium medium;
            background-color: #5B0000;
            background-image: url('/Song/ImageStatic/bg_header_down.gif/1/1' );
            background-repeat: repeat-x;
            color: #FFFFFF;
            text-align: center;
            font-size: 1em;
            font-weight: bold;
            border-top-style: solid;
            border-top-color: #000000; /*position: absolute;               bottom: 1;          padding-top: 10px;     margin-top: 50px;     width: 100%;*/
        }
        
        #footer a
        {
            color: White;
            font-size: 0.9em;
            text-decoration: none;
        }
        #footer a:hover
        {
            font-size: 0.9em;
            text-decoration: underline;
        }
    </style>
    <script runat="server">
        string[] fontSizes = new[] { "12px", "14px", "16px", "18px", "20px", "22px", "24px" };
        string GetMoodCloudHtml()
        {
            var viewData = (StartDetailData)ViewData.Model;
            var minWeight = decimal.MaxValue;
            var maxWeight = decimal.MinValue;

            List<CloudHolder> moodItems = viewData.AllMoods.OrderBy(x => Guid.NewGuid()).ToList();


            foreach (var mood in moodItems)
            {
                if (mood.counter < minWeight)
                {
                    minWeight = (decimal)mood.counter;
                }

                if (mood.counter > maxWeight)
                {
                    maxWeight = (decimal)mood.counter;
                }
            }


            var scaleUnitLength = (maxWeight - minWeight + 1) / Convert.ToDecimal(fontSizes.Length);

            var moodCloudHtml = new StringBuilder();

            foreach (var moodItem in moodItems)
            {
                var fontSizeIndex = Convert.ToInt32(Math.Truncate(((int)moodItem.counter - minWeight) / scaleUnitLength));
                var encodedTag = moodItem.mood.UrlEncode();
                var link = Html.ActionLink(moodItem.mood, "Search", "Song", new { q = moodItem.mood, weight = moodItem.counter, searchType = "Mood" }, new { style = ("font-size:" + fontSizes[fontSizeIndex]) });
                moodCloudHtml.AppendFormat("<span>{0}</span> ", link);
            }
            return moodCloudHtml.ToString();
        }

        string GetWeatherCloudHtml()
        {
            var viewData = (BaseViewData)ViewData.Model;
            var weatherCloud = new StringBuilder();


            var link = Html.ActionLink("Weather Music", "CategoryWeather", "Song", null, new { style = ("font-size: 10") });
            weatherCloud.AppendFormat("<span>{0}</span> ", link);

            foreach (var category in viewData.Categories)
            {
                string encodedCategory = category.Name.UrlEncode();
                link = Html.ActionLink(category.Name, "CategoryWeather", "Song", new { name = encodedCategory, page = 1 }, new { style = ("font-size: 10") });
                weatherCloud.AppendFormat("<span>{0}</span> ", link);
            }

            link = Html.ActionLink("Top Popular 2010 Love Songs", "TopPopular2010LoveSongs", "Song", null, new { style = ("font-size: 10") });
            weatherCloud.AppendFormat("<span>{0}</span> ", link);
            link = Html.ActionLink("Top Popular Love Songs", "TopPopularLoveSongs", "Song", null, new { style = ("font-size: 10") });
            weatherCloud.AppendFormat("<span>{0}</span> ", link);

            return weatherCloud.ToString();
        }

        string GetArtistCloudHtml()
        {
            var viewData = (StartDetailData)ViewData.Model;
            var minWeight = decimal.MaxValue;
            var maxWeight = decimal.MinValue;

            List<CloudHolder> moodItems = viewData.RandArtists.OrderBy(x => Guid.NewGuid()).ToList();

            foreach (var mood in moodItems)
            {
                if (mood.counter < minWeight)
                {
                    minWeight = (decimal)mood.counter;
                }

                if (mood.counter > maxWeight)
                {
                    maxWeight = (decimal)mood.counter;
                }
            }


            var scaleUnitLength = (maxWeight - minWeight + 1) / Convert.ToDecimal(fontSizes.Length);

            var moodCloudHtml = new StringBuilder();

            foreach (var moodItem in moodItems)
            {
                var fontSizeIndex = Convert.ToInt32(Math.Truncate(((int)moodItem.counter - minWeight) / scaleUnitLength));
                var encodedTag = moodItem.mood.UrlEncode();
                var link = Html.ActionLink(moodItem.mood, "Index", "Artist", new { artistName = moodItem.mood }, new { style = ("font-size:" + fontSizes[fontSizeIndex]) });
                moodCloudHtml.AppendFormat("<span>{0}</span> ", link);
            }
            return moodCloudHtml.ToString();
        }

        string GetSongCloudHtml()
        {
            var viewData = (StartDetailData)ViewData.Model;
            var minWeight = decimal.MaxValue;
            var maxWeight = decimal.MinValue;

            List<CloudHolder> moodItems = viewData.RandSong.OrderBy(x => Guid.NewGuid()).ToList();

            foreach (var mood in moodItems)
            {
                if (mood.counter < minWeight)
                {
                    minWeight = (decimal)mood.counter;
                }

                if (mood.counter > maxWeight)
                {
                    maxWeight = (decimal)mood.counter;
                }
            }

            var scaleUnitLength = (maxWeight - minWeight + 1) / Convert.ToDecimal(fontSizes.Length);

            var moodCloudHtml = new StringBuilder();

            foreach (var moodItem in moodItems)
            {
                var fontSizeIndex = Convert.ToInt32(Math.Truncate(((int)moodItem.counter - minWeight) / scaleUnitLength));
                var encodedTag = moodItem.mood.UrlEncode();
                var link = Html.ActionLink(moodItem.mood, "Detail", "Song", new { id = moodItem.id }, new { style = ("font-size:" + fontSizes[fontSizeIndex]) });
                moodCloudHtml.AppendFormat("<span>{0}</span> ", link);
            }
            return moodCloudHtml.ToString();
        }
    </script>
</head>
<body>
    <% var viewData = ((StartDetailData)ViewData.Model); %>
    <div id="wrapper">
        <div id="header">
            <div class="title">
                <%= Html.Image(Url.Content("~/Song/ImageStatic/Banner.jpg/540/77"), "banner", new { width = "540", height = "77", Style="border:0px solid;width: 540px;height: 77px;"  })%>
            </div>
        </div>
        <div id="subContainer">
            <div id="promoText">
                <h1 class="mainTitle">
                    Need new ways to listen to music?</h1>
                <p class="promo">
                    Ilovethismusic.com lets you listen & download music based on your <strong>mood, weather,</strong>
                    or any type of <strong>expression</strong> you can think of. Just press <strong>Play.</strong>
                </p>
                <p style="font-size: 10px; color: #AAA;">
                    ilovethismusic.com is a <a style="color: #AAA;" href="/Song/License/">licensed</a>
                    music site (Licensed by BMI and ASCAP).
                </p>
            </div>
            <div id="facebookLikes">
                <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
                <fb:like href="http://www.ilovethismusic.com/" show_faces="true" width="450" font=""></fb:like>
            </div>
        </div>
        <div id="searchBox">
            <% using (Html.BeginForm("Search", "Song", FormMethod.Get, new { id = "frmSearch", name = "frmSearch" })) %>
            <% { %>
            <table class="form" style="width: 70%; margin-right: auto; margin-left: auto;">
                <tr>
                    <td>
                        <input class="searchBox" id="q" name="q" type="text" maxlength="2048" value="<%= Server.HtmlEncode(viewData.AllMoods.OrderBy(x => Guid.NewGuid()).ToList().FirstOrDefault().mood) %>" />
                    </td>
                    <td style="height: 25px; width: 25px;" rowspan="2">
                        <input type="submit" class="playButton" value="Play" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <select id="searchType" name="searchType" class="dhtmlselect">
                            <option value="ArtistGroup">Artist/Group</option>
                            <option value="Song">Song</option>
                            <option value="Mood" selected="selected">Mood</option>
                            <option value="Expression">Expression</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <%= Html.RadioButton("songFormat", "1") %>
                        Audio
                        <%= Html.RadioButton("songFormat", "2",true) %>
                        Audio and Video
                    </td>
                </tr>
            </table>
            <% } %>
        </div>
        <div id="clouds" class="clouds">
            <table class="form">
                <tr>
                    <td valign="top">
                        <h2>
                            Moods</h2>
                        <div id="moodCloud" class="moodCloud">
                            <%= GetMoodCloudHtml()%>
                        </div>
                    </td>
                    <td valign="top">
                        <h2>
                            Popular artists</h2>
                        <div id="artistCloud" class="artistCloud">
                            <%= GetArtistCloudHtml()%>
                        </div>
                    </td>
                    <td valign="top">
                        <h2>
                            Popular songs</h2>
                        <div id="songCloud" class="songCloud">
                            <%= GetSongCloudHtml()%>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
        <div id="footer">
            <p>
                <a href="/">home</a> |<a href="/Song/License/">license</a> |<a href="/Song/Privacy/">privacy</a>
                |<a href="/Song/About/">about us</a> |<a href="/Song/Contact">contact us</a></p>
            <p style="font-weight: normal; font-size: 0.8em;">
                Copyright ILoveThisMusic.com (c) 2011. All rights reserved
            </p>
        </div>
    </div>
    <script type="text/javascript">
        var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
        document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
        var pageTracker = _gat._getTracker("UA-6279054-1");
        pageTracker._trackPageview();
    </script>
</body>
</html>
